
// 弹出JavaScript小窗口
public static void Alert(string message)
{
	#region
	string js = @"<Script language='JavaScript'>
			alert('" + message + "');</Script>";
	HttpContext.Current.Response.Write(js);
	#endregion
}

// 弹出消息框并且转向到新的URL
public static void AlertAndRedirect(string message, string toURL)
{
	#region
	string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
	HttpContext.Current.Response.Write(string.Format(js, message, toURL));
	#endregion
}

// 回到历史页面
public static void GoHistory(int value)
{
	#region
	string js = @"<Script language='JavaScript'>
			history.go({0});  
		  </Script>";
	HttpContext.Current.Response.Write(string.Format(js, value));
	#endregion
}

// 关闭当前窗口
public static void CloseWindow()
{
	#region
	string js = @"<Script language='JavaScript'>
			parent.opener=null;window.close();  
		  </Script>";
	HttpContext.Current.Response.Write(js);
	HttpContext.Current.Response.End();
	#endregion
}

// 刷新父窗口
public static void RefreshParent(string url)
{
	#region
	string js = @"<Script language='JavaScript'>
			window.opener.location.href='"+url+"';window.close();</Script>";
	HttpContext.Current.Response.Write(js);
	#endregion
}


// 刷新打开窗口
public static void RefreshOpener()
{
	#region
	string js = @"<Script language='JavaScript'>
			opener.location.reload();
		  </Script>";
	HttpContext.Current.Response.Write(js);
	#endregion
}


// 打开指定大小的新窗体
public static void OpenWebFormSize(string url, int width,int heigth,int top,int left)
{
	#region
	string js = @"<Script language='JavaScript'>window.open('" + url + @"','','height=" + heigth + ",width=" + width + ",top="+top+",left="+left+",location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');</Script>";

	HttpContext.Current.Response.Write(js);
	#endregion
}


// 转向Url制定的页面
public static void JavaScriptLocationHref(string url)
{
	#region
	string js = @"<Script language='JavaScript'>
			window.location.replace('{0}');
		  </Script>";
	js = string.Format(js, url);
	HttpContext.Current.Response.Write(js);
	#endregion
}

// 打开指定大小位置的模式对话框
public static void ShowModalDialogWindow(string webFormUrl, int width, int height, int top, int left)
{
	#region
	string features = "dialogWidth:" + width.ToString() + "px"
		+ ";dialogHeight:" + height.ToString() + "px"
		+ ";dialogLeft:" + left.ToString() + "px"
		+ ";dialogTop:" + top.ToString() + "px"
		+ ";center:yes;help=no;resizable:no;status:no;scroll=yes";
	ShowModalDialogWindow(webFormUrl, features);
	#endregion
}


//全选
function selectAll(){
  var chkAll=document.getElementById("cbChooseAll");
  if(chkAll.checked){
    for(var i=0;i<form1.elements.length;i++){   
      if(form1.elements[i].type=="checkbox"){
        form1.elements[i].checked = true;
      }
    }
  }
  else{
    for(var i=0;i<form1.elements.length;i++){   
      if(form1.elements[i].type=="checkbox"){
        form1.elements[i].checked = false;
      }
    } 
  }
}


//还原所有控件
function ClearAllControls() 
{
  for (i=0; i<document.forms[0].length; i++)
  {
       var doc = document.forms[0].elements[i];
    
        switch (doc.type) 
        {
          case "text" :
                doc.value = "";
                break;
          case "checkbox" :
                doc.checked = false;
                break;    
          case "radio" :
                doc.checked = false;
                break;      
          case "select-one" :
                doc.selectedIndex = 0;
                break;                      
          case "select-multiple" :
                doc.selectedIndex = 0;
                break;  
          default :
                break;
        }
  }
}